package com.dcm.bargain.controller;

import com.dcm.bargain.client.OrderClient;
import com.dcm.bargain.entity.CutPriceEntity;
import com.dcm.bargain.service.RecordService;
import com.dcm.common.annotation.EnableResponseBodyAdvice;
import com.dcm.common.vo.CommonResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author Mengxiangjian
 * @Date: 2021/4/1 9:58
 * @Version V 1.0
 */
@RestController
@RequestMapping("/record")
@EnableResponseBodyAdvice
public class RecordController {

    @Autowired
    private RecordService recordService;

    @Autowired
    private OrderClient orderClient;

    /**
     * 查找所有
     * @return
     */
    @ApiOperation("查询所有")
    @GetMapping("/findAll")
    public List<CutPriceEntity> findAll(@RequestParam("uid")Long uid){
        return recordService.findAll(uid);
    }

    /**
     * 显示帮砍的好友
     * @return
     */
    @ApiOperation("查询帮砍的好友")
    @GetMapping("/findHelper")
    public List<String> findHelper(@RequestParam("uid")Long uid, @RequestParam("bid")Long bid){
        return recordService.findHelper(uid,bid);
    }

    /**
     * 倒叙
     * @return
     */
    @ApiOperation("倒序")
    @GetMapping("/findAllDesc")
    public List<CutPriceEntity> findAllDesc(){
        return recordService.findAllDesc();
    }

    /**
     * 倒叙
     * @return
     */
    @ApiOperation("发货")
    @GetMapping("/findAllDpt")
    public List<CutPriceEntity> findAllDpt(){
        return recordService.findAllDpt();
    }

    /**
     * 倒叙
     * @return
     */
    @ApiOperation("地址")
    @GetMapping("/findAllDty")
    public CommonResponse findAllDty(@RequestParam("uid")Long uid){
        return orderClient.findAllDty(uid);
    }

}
